package com.chanel.iamframework.core.dao;

import com.chanel.iamframework.core.domain.User;

public interface UserDAO {
	
	/**
	 * Persiste User entity
	 * @param user entity
	 * @return The number of rows affected by the insert
	 */
	int createUser(User user);
	
	/**
	 * Get User by Identity
	 * @param userId Identity of User
	 * @return Users entity
	 */
	User getUser(Long userId);
	
	/**
	 * Update User entity
	 * @param user entity
	 * @return The number of rows affected by the insert
	 */
	int updateUser(User user);
	
	/**
	 * Delete User by Identity
	 * @param userId Identity
	 * @return The number of rows affected by the insert
	 */
	int deleteUser(Long userId);

	/**
	 * Load Groups by UserId into the returned {@link User} instance.
	 * @param userId identity
	 * @return {@link User} instance with list of {@link com.chanel.iamframework.core.domain.Group}
	 */
	User loadGroups(Long userId);

	/**
	 * Load Application by userId into the returned {@link User} instance.
	 * @param userId identity
	 * @return {@link User} instance with list of {@link com.chanel.iamframework.core.domain.Application}
	 */
	User loadApplications(Long userId);

	/**
	 * Load Role by userId into the returned {@link User} instance.
	 * @param userId identity
	 * @return {@link User} instance with list of {@link com.chanel.iamframework.core.domain.Role}
	 */
	User loadRoles(Long userId);

	/**
	 * Add Group, User association
	 * @param groupId identity
	 * @param userId identity
	 * @return The number of rows affected by the insert
	 */
	int addGroup(Long groupId, Long userId);

	/**
	 * Delete Group, User association
	 * @param groupId identity
	 * @param userId identity
	 * @return The number of rows affected by the insert
	 */
	int deleteGroup(Long groupId, Long userId);
}